package com.create404.suishoupai.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.create404.suishoupai.dto.CommentedNewsDto;
import com.create404.suishoupai.entity.NewsComment;
import com.create404.suishoupai.vo.NewsCommentListItemVO;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author create404
 * @since 2021-07-17
 */
public interface NewsCommentMapper extends BaseMapper<NewsComment> {

    /**
     * 获取新闻评论列表
     *
     * @param newsId
     * @return
     */
    @Select("SELECT news_comment.*, employee.`name`, employee.`avatar` FROM news_comment INNER JOIN employee ON news_comment.employee_id = employee.employee_id AND news_comment.news_id = #{newsId}")
    List<NewsCommentListItemVO> getNewsCommentList(String newsId);

    IPage<CommentedNewsDto> getCommentedNews(Page<?> page, String employeeId);
}
